home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13384 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Intraprocess piping into an array
  5. Followup-To: comp.unix.programmer
  6. Date: Sun, 07 Apr 96 18:30:31 GMT
  7. Organization: none
  8. Message-ID: <828901831snz@genesis.demon.co.uk>
  9. References: <4k6r1p$eoh@news.tiac.net>
  10. Reply-To: fred@genesis.demon.co.uk
  11. X-NNTP-Posting-Host: genesis.demon.co.uk
  12. X-Newsreader: Demon Internet Simple News v1.27
  13. X-Mail2News-Path: genesis.demon.co.uk
  14.  
  15. In article <4k6r1p$eoh@news.tiac.net> craigm@max.tiac.net "Craig Mattson" writes:
  16.  
  17. >I'd like to pipe stdout into an array so I can process it before
  18. >it actually gets printed.  However, I don't want to fork a process
  19. >just to read the array as it's being output.  Here's what I've been
  20. >trying to do, which works until the output gets too large:
  21.  
  22. You're talking about thinks like fork, pipe, close, dup, fdopen which are
  23. not defined by the C language. They are system calls defined by Unix and
  24. should be discussed in comp.unix.programmer.
  25.  
  26. >The problem is that the fflush() tries to flush the _whole_ buffer,
  27. >which is often too large for the standard buffer size for the read end
  28. >of the pipe.
  29.  
  30. No reads are involved at the time you call fflush(stdout) so the read
  31. buffer size is not relevant. Make sure the pipe is empty before you call
  32. fflush() and the write buffer size is less than the pipe buffer size (often
  33. about 4K), although the real issue is to ensure that you haven't written
  34. more than the pipe buffer size between reads, which is what will lock you
  35. up. Followups to comp.unix.programmer.
  36.  
  37. -- 
  38. -----------------------------------------
  39. Lawrence Kirby | fred@genesis.demon.co.uk
  40. Wilts, England | 70734.126@compuserve.com
  41. -----------------------------------------
  42.